/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Nas
 */
@Entity
@Table(name = "AFILIACION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Afiliacion.findAll", query = "SELECT a FROM Afiliacion a"),
    @NamedQuery(name = "Afiliacion.maxId", query = "SELECT max(a.idAfiliacion) as maxId FROM Afiliacion a"),
    @NamedQuery(name = "Afiliacion.findByIdAfiliado", query = "SELECT a FROM Afiliacion a JOIN FETCH a.idAfiliado WHERE a.idAfiliado.idAfiliado = :idAfiliado"),
    @NamedQuery(name = "Afiliacion.findByIdAfiliacion", query = "SELECT a FROM Afiliacion a WHERE a.idAfiliacion = :idAfiliacion"),
    @NamedQuery(name = "Afiliacion.findByIdCuenta", query = "SELECT a FROM Afiliacion a WHERE a.idCuenta = :idCuenta"),
    @NamedQuery(name = "Afiliacion.findByFechaIni", query = "SELECT a FROM Afiliacion a WHERE a.fechaIni = :fechaIni"),
    @NamedQuery(name = "Afiliacion.findByFechaFin", query = "SELECT a FROM Afiliacion a WHERE a.fechaFin = :fechaFin"),
    @NamedQuery(name = "Afiliacion.findByEstado", query = "SELECT a FROM Afiliacion a WHERE a.estado = :estado"),
    @NamedQuery(name = "Afiliacion.findByEstadoAndAfiliado", query = "SELECT a FROM Afiliacion a  JOIN FETCH a.idAfiliado WHERE a.idAfiliado.idAfiliado = :idAfiliado and  a.estado = :estado"),
    
    @NamedQuery(name = "Afiliacion.findByFechaCreate", query = "SELECT a FROM Afiliacion a WHERE a.fechaCreate = :fechaCreate"),
    @NamedQuery(name = "Afiliacion.findByCreateBy", query = "SELECT a FROM Afiliacion a WHERE a.createBy = :createBy"),
    @NamedQuery(name = "Afiliacion.findByModifiedBy", query = "SELECT a FROM Afiliacion a WHERE a.modifiedBy = :modifiedBy"),
    @NamedQuery(name = "Afiliacion.findByFechaModified", query = "SELECT a FROM Afiliacion a WHERE a.fechaModified = :fechaModified"),
    @NamedQuery(name = "Afiliacion.findByNroFactura", query = "SELECT a FROM Afiliacion a WHERE a.nroFactura = :nroFactura")})
public class Afiliacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id    
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "ID_AFILIACION")
    private Integer idAfiliacion;
    @Column(name = "ID_CUENTA")
    private Integer idCuenta;
    @Column(name = "FECHA_INI")
    @Temporal(TemporalType.DATE)
    private Date fechaIni;
    @Column(name = "FECHA_FIN")
    @Temporal(TemporalType.DATE)
    private Date fechaFin;
    @Column(name = "ESTADO")
    private String estado;
    @Column(name = "FECHA_CREATE")
    @Temporal(TemporalType.DATE)
    private Date fechaCreate;
    @Column(name = "CREATE_BY")
    private Integer createBy;
    @Column(name = "MODIFIED_BY")
    private Integer modifiedBy;
    @Column(name = "FECHA_MODIFIED")
    @Temporal(TemporalType.DATE)
    private Date fechaModified;
    @Column(name = "NRO_FACTURA")
    private String nroFactura;
    @JoinColumn(name = "ID_PLAN", referencedColumnName = "ID_PLAN")
    @ManyToOne
    private Plan idPlan;
    @JoinColumn(name = "ID_CATEGORIA", referencedColumnName = "ID_CATEGORIA")
    @ManyToOne
    private Categoria idCategoria;
    @JoinColumn(name = "ID_AFILIADO", referencedColumnName = "ID_AFILIADO")
    @ManyToOne
    private Afiliado idAfiliado;

    public Afiliacion() {
    }

    public Afiliacion(Integer idAfiliacion) {
        this.idAfiliacion = idAfiliacion;
    }

    public Integer getIdAfiliacion() {
        return idAfiliacion;
    }

    public void setIdAfiliacion(Integer idAfiliacion) {
        this.idAfiliacion = idAfiliacion;
    }

    public Integer getIdCuenta() {
        return idCuenta;
    }

    public void setIdCuenta(Integer idCuenta) {
        this.idCuenta = idCuenta;
    }

    public Date getFechaIni() {
        return fechaIni;
    }

    public void setFechaIni(Date fechaIni) {
        this.fechaIni = fechaIni;
    }

    public Date getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Date fechaFin) {
        this.fechaFin = fechaFin;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    public Date getFechaCreate() {
        return fechaCreate;
    }

    public void setFechaCreate(Date fechaCreate) {
        this.fechaCreate = fechaCreate;
    }

    public Integer getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Integer createBy) {
        this.createBy = createBy;
    }

    public Integer getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(Integer modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public Date getFechaModified() {
        return fechaModified;
    }

    public void setFechaModified(Date fechaModified) {
        this.fechaModified = fechaModified;
    }

    public String getNroFactura() {
        return nroFactura;
    }

    public void setNroFactura(String nroFactura) {
        this.nroFactura = nroFactura;
    }

    public Plan getIdPlan() {
        return idPlan;
    }

    public void setIdPlan(Plan idPlan) {
        this.idPlan = idPlan;
    }

    public Categoria getIdCategoria() {
        return idCategoria;
    }

    public void setIdCategoria(Categoria idCategoria) {
        this.idCategoria = idCategoria;
    }

    public Afiliado getIdAfiliado() {
        return idAfiliado;
    }

    public void setIdAfiliado(Afiliado idAfiliado) {
        this.idAfiliado = idAfiliado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAfiliacion != null ? idAfiliacion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Afiliacion)) {
            return false;
        }
        Afiliacion other = (Afiliacion) object;
        if ((this.idAfiliacion == null && other.idAfiliacion != null) || (this.idAfiliacion != null && !this.idAfiliacion.equals(other.idAfiliacion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.Afiliacion[ idAfiliacion=" + idAfiliacion + " ]";
    }
    
}
